#include <iostream>
#include <vector>
#include <stack>

using namespace std;

bool IsPopOrder(vector<int> pushV, vector<int> popV) {
	int pushSize = pushV.size(), popSize = popV.size();
	if (pushSize == 0) return false;
	if (pushSize != popSize)
		return false;
	stack<int> data_s;
	int i = 0;
	for (int j = 0; j < popSize; ++j)
	{
		while (i < pushSize && (data_s.empty() || popV[j] != data_s.top()))
		{
			data_s.push(pushV[i]);
			++i;
		}

		if (popV[j] != data_s.top())
			return false;
		data_s.pop();
		
	}
	return true;
}


//int main()
//{
//	vector<int> push = { 1,2,3,4,5}, pop = { 4,3,5,1,2 };
//	cout << IsPopOrder(push, pop);
//	system("pause");
//	return 0;
//}